package 剑指offer;

import java.util.Arrays;

/**
 * 扑克牌中的顺子
 */
public class Offer61_JZ {
    public boolean isStraight(int[] nums) {
        Arrays.sort(nums);
        int joker = 0;
        for (int i=0; i<4; i++) {
            if (nums[i] == 0) {
                joker++;
            } else if (nums[i] == nums[i+1]) {
                return false;
            }
        }
        return nums[4] - nums[joker] < 5;
    }

    public static void main(String[] args) {
        Offer61_JZ demo = new Offer61_JZ();
        int[] nums = {0,0,8,5,4};
        System.out.println(demo.isStraight(nums));
    }
}
